<?php
/**
 * 视图
 * @link https://ym2.cleverstone.top
 * @copyright Copyright (c) 2020 Yii Manager Software LLC
 */
use yii\helpers\Json;
use builder\helper\H5;
/** @var \yii\web\View $this 视图组件 */
/** @var \builder\menu\MenuBuilder $context 当前组件 */
/** @var array $rootLayout 根布局 */
/** @var array $menuLayout 菜单布局 */
/** @var array $menuToolbar 工具栏 */
$context = $this->context;
?>

<div class="p-3 menu-comp <?= $rootLayout['class'] ?>"
     ng-controller="ym2.ctrl.<?= $context->id ?>"
     style="<?= $rootLayout['style'] ?>"
     <?= $rootLayout['attribute'] ?>>
    <!--菜单开始-->
    <?= $context->beginMenu() ?>

    <!--顶部工具栏-->
    <?php if (!empty($menuToolbar['top'])): ?>

    <div class="layui-btn-container pt-2 pl-2">
        <?php foreach ($menuToolbar['top'] as $item): ?>

        <button class="layui-btn layui-btn-sm <?= $item['btnClass'] ?>" ng-click="toolbarAction(<?= H5::encode(Json::encode($item)) ?>)">
            <?php if (!empty($item['icon'])): ?>

            <span class="<?= $item['icon'] ?>"></span>
            <?php endif; ?>

            <?= $item['title'] ?>
        </button>
        <?php endforeach; ?>

    </div>
    <?php endif; ?>

    <div id="<?= $context->id ?>"
         ng-hide="loadingState"
         class="pl-2 py-2 <?= $menuLayout['class'] ?>"
         style="<?= $rootLayout['style'] ?>"
         <?= $rootLayout['attribute'] ?>></div>
    <div ng-show="loadingState" class="w-100 d-flex justify-content-center align-items-center py-4">
        <i class="layui-icon layui-icon-loading-1 layui-anim layui-anim-rotate layui-anim-loop"></i>
    </div>
    <!--底部工具栏-->
    <?php if (!empty($menuToolbar['bottom'])): ?>

        <div class="layui-btn-container pt-2 pl-2">
            <?php foreach ($menuToolbar['bottom'] as $item): ?>

            <button class="layui-btn layui-btn-sm <?= $item['btnClass'] ?>" ng-click="toolbarAction(<?= H5::encode(Json::encode($item)) ?>)">
                <?php if (!empty($item['icon'])): ?>

                <span class="<?= $item['icon'] ?>"></span>
                <?php endif; ?>

                <?= $item['title'] ?>
            </button>
            <?php endforeach; ?>

        </div>
    <?php endif; ?>

    <!--菜单结束-->
    <?= $context->endMenu() ?>
</div>
